﻿using System.Collections.Generic;
using System.Windows;
using System;
namespace Silvery.Role
{
    /// <summary>
    /// 角色零件集类
    /// </summary>
    public class RolePartCollection : Dictionary<string, FrameworkElement>,IDisposable
    {
        Role RoleRoot;
        public RolePartCollection(Role roleroot)
        {
            RoleRoot = roleroot;
        }

        public new void Add(string key ,FrameworkElement value)
        {
            base.Add(key,value);
            RoleRoot.Children.Add(value);
        }
        public new void Remove(string key)
        {
            if (base.ContainsKey(key))
            {
                RoleRoot.Children.Remove(base[key]);
                base.Remove(key);
            }
        }


        public void Dispose()
        {
            foreach (var item in this.Values)
            {
                RoleRoot.Children.Remove(item);
            }
            RoleRoot = null;
        }
    }
}
